clc
clear
close all

hranice=50;
krok=0.1;
vec=-hranice:krok:hranice;
[x,y]=meshgrid(vec,vec);
u=[0;0;pi/2;0;0]
z=isStableSys(x,y,u);
mesh(x,y,z);
saveas(gcf,'mesh.fig');

save stable x y z

%% kontola velikosti

param.a=1.446;
param.b=1.408;
param.c=1.4370;
param.I=1549.034;
param.m=2220;
param.g=9.81;

minimum=realmax();
maximum=realmin();
for i=1:length(vec);
    for j=1:length(vec);
        if(x(i,j)<0 && z(i,j)==0)
            [A,~,~,~]=carLin([y(i,j);x(i,j);zeros(4,1)],u,param);
            eigv=eig(A);
            minimum=min([minimum;eigv(eigv>0)]);
            maximum=max([maximum;eigv(eigv>0)]);
        end
    end
end
minimum
maximum